#include<stdio.h>
#include<iostream>
#include<list>
using namespace std;

struct ListNode {
      int val;  //当前结点的值
      ListNode *next;  //指向下一个结点的指针
      ListNode(int x) : val(x), next(NULL) {}  //初始化当前结点值为x,指针为空
};

class Solution{
    public:
        ListNode* addTwoNumbers(ListNode* l1,ListNode* l2){
            ListNode* result = new ListNode(0);
            ListNode* p = l1;
            ListNode* q = l2;
            ListNode* s = result;
            int sum = 0;
            while((p != NULL) ||(q != NULL)){
                sum /= 10;
                if(p != NULL){
                    sum += p->val;
                    p = p->next;
                }
                if(q != NULL){
                    sum += q->val;
                    q = q->next;
                }
                //s->val = sum%10;
                s->next = new ListNode(sum %10);
                s = s->next;
            }
            if((sum/10) ==1){
                s->next = new ListNode(1);
            }
            return result->next;
        }

};
ListNode* initListNode(){
    ListNode* ln = new ListNode(0);
    ListNode* temp = ln;
    char c;
    int num;
    while((c = getchar() != '\n')){
        if(c != ' '){
            ungetc(c,stdin);
            cin >> num;
            ListNode* temp1;
            temp1 = new ListNode(num);
            
            ln->next = temp1;
            temp = temp->next;
        }
    }
}
int main(){
    ListNode* l1 = new ListNode(1);
    l1->next = new ListNode(2);
    ListNode* l2;
    return 0;
}